<?php

// Check if lock file exists.

$filename = './lock.php';

if (file_exists($filename))
{
	die ("Error: You have already installed MyBW. If you need to reinstall it, maybe to reset the mysql connection detials, please delete the 'lock.php' file in the install directory.");
}
else // If the lock file doesn't exist, continue with the install.
{
}


$mysqluser = $_POST['mysql_user'];
$mysqlpass = $_POST['mysql_pass'];
$mysqlhost = $_POST['mysql_host'];
$mysqldb = $_POST['mysql_db'];

$writetofile = '<?php
//Connection Details
$dbuser = "' . $mysqluser . '";
$dbhost = "' . $mysqlhost . '";
$dbpass = "' . $mysqlpass . '";
$dbname = "' . $mysqldb . '";
?>
';

$FileName = "../mysql.php";
$FileHandle = fopen($FileName, 'w');
fclose($FileHandle);

$fh = fopen($FileName, 'w') or die("can't open file");
fwrite($fh, $writetofile);
fclose($fh);



?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<link type="text/css" href="./styles.css" rel="stylesheet" media="screen" />

		<title>Install MyBW - Default Admin Details</title>
	</head>

	<body>
		<div id="container">
			<div id="header">
				<img src="../inc/images/logo-300-up.png" alt="MyBW" />
			</div>
			
				<div id="foxmenucontainer">
					<div id="foxmenu">
						<ul>
							<li><a href="#">MySQL Details</a></li>
							<li><a href="#" class="current">Default Admin Details</a></li>
							<li><a href="#">Finish</a></li>
						</ul>
					</div>
				</div>
				
			<div id="content">				
		<p><h3>Default Admin Details</h3>
		
		<table width="100%" border=0>
		
		<form action="./finish.php" method="POST">
				
		<tr>
		<td class="alt"><b>Username:</b></td>
		<td class="alt"><input type="text" name="username" value="admin" /></td>
		</tr>
		
		<tr>
		<td><b>Password:</b></td>
		<td><input type="text" name="password" /></td>
		</tr>
		
		<tr>
		<td class="alt"><b>Email:</b></td>
		<td class="alt"><input type="text" name="email" /></td>
		</tr>
		
		<tr>
		<td><b>Theme:</b></td>
		<td><input type="text" name="mysql_pass" value="Default" Disabled /> <i><small>You can change the theme in your preferences once you are logged in.</small></i></td>
		</tr>
		
		</table>
		<br />
		
		<center><input type="submit" value="Finish >" /></center>
		
		</form></p>

			</div>
			<div id="footer">
				<a href="http://mybw.co.uk/forums/showthread.php?tid=16">Installation</a> &nbsp; &nbsp; 
				<a href="http://mybw.co.uk/forums/">Support Forums</a> &nbsp; &nbsp; 
				<a href="http://mybw.co.uk/license.php">License</a>
			</div>
		</div>
	</body>
</html>
